﻿    private static void inspect_FOV()
        {
            #region ***** 单面常规检测流程 *****

            switch (WorkingProcess.iStep)
            {
                case 0:
                    {
                        WorkingProcess.iStep++;
                    }
                    break;

                case 1://wait last board
                    {
                        if (clsThreadPool.AIPool.isBusy())//wait ai done
                        {
                            clsMachine.qtMsgShow("等待AI处理结束" + WorkingProcess.iCounter / TimerSpan);
                            WorkingProcess.iCounter++;
                        }
                        else if (clsThreadPool.DataUploadPool.isBusy()) //wait dataupload//wells0065
                        {
                            clsMachine.qtMsgShow("等待结果上传结束" + WorkingProcess.iCounter / TimerSpan);
                            WorkingProcess.iCounter++;
                        }
                        else
                        {
                            clsMachine.theMain.setInspectResult(false, true);
                            clsMachine.m_pAllPcb[0].clearMemory();
                            clsMachine.m_pAllPcb[0].applyMarkCenter_AllPartAndView();
                            clsMachine.m_pAllPcb[0].clearEditView();
                            clsMachine.m_pAllPcb[0].resetPcbImageWhole();
                            clsMachine.clearBuffer3D();
                            clsMachine.theMotion.setLight(tagMachineLightingStatus.STA_Running);
                            clsMachine.theMotion.setDo(tagDoCommand.SMEMA_MachineReady_Out, false);
                            swInspect.Restart();//wells0064
                            WorkingProcess.iCounter = 0;
                            WorkingProcess.iStep++;
                        }
                    }
                    break;

                case 2:
                    {
                        clsMachine.updateRemoteProgram(false);
                        WorkingProcess.iStep++;
                    }
                    break;

                case 3://reset data
                    {
                        outputOKNGSignal(tagOutputOkNg.Reset);

                        clsMachine.m_pAllPcb[0].resetAll();//wells0033

                        clsMachine.nowPcb.reset(0);//wells0047

                        clsMachine.theMain.updateStatics(false);

                        clsMachine.theMain.repaint();//wells0056//刷新元件状态

                        clsMachine.aiCreatePath();

                        clsMachine.adjustZServoHeight(clsMachine.m_pAllPcb[0].Rail == tagPcbRail.轨道2);

                        WorkingProcess.iStep++;
                    }
                    break;

                case 4://prepare for readdata
                    {
                        clsMachine.qtMsgShow("读取通讯数据");

                        if (!clsMachine.readInputData())
                        {
                            clsMachine.qtShowAlarm("无法读取输入数据，请确认！");
                            WorkingProcess.bEnd = true;
                        }

                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;

                case 5://
                    {
                        clsMachine.qtMsgShow("准备读取下次通讯数据");

                        clsMachine.prepareReadInputData();

                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;

                case 6://wait capture
                    {
                        ExecutePlugin(Method.Start);
                    }
                    break;

                case 7://blend
                    {
                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;

                case 8:
                    {
                        ExecutePlugin(Method.BeforeProductIn);
                    }
                    break;

                case 9://inspect mark
                    {
                        if (!doInspectPart_FOV(tagViewType.MarkView))
                        {
                            WorkingProcess.bEnd = true;
                        }

                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;

                case 10:
                    {
                        isReadyToGo();
                    }
                    break;

                case 11://wait mark inspect
                    {
                        clsMachine.qtMsgShow("处理-Mark-" + WorkingProcess.iCounter / TimerSpan);

                        isInspectReadyToGo();
                    }
                    break;

                case 12://judge mark
                    {
                        clsMachine.theMain.repaint();

                        if (clsMachine.m_pAllPcb[0].m_bMarkError)
                        {
                            clsMachine.qtShowAlarm(clsMachine.m_pAllPcb[0].Side.ToString() + "MARK点错误！请调试程序！");
                            WorkingProcess.bEnd = true;
                            return;
                        }
                        else
                        {
                            clsMachine.m_pAllPcb[0].m_bMarkInit = true;
                            clsMachine.m_pAllPcb[0].calMainMarkResult();
                            clsMachine.m_pAllPcb[0].adjustPartsAndFovs_MainMark();

                            clsMachine.theMain.repaint();

                            WorkingProcess.iStep++;
                        }

                        if (WorkingProcess.seq == tagSequence.seq_ManualInspectMark)//wells0071
                        {
                            WorkingProcess.bEnd = true;
                        }
                    }
                    break;

                case 13://inspect badmark
                    {
                        clsMachine.theMain.repaint();

                        if (!doInspectPart_FOV(tagViewType.BadMarkView))
                        {
                            WorkingProcess.bEnd = true;
                        }

                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;

                case 14:
                    {
                        isReadyToGo();
                    }
                    break;

                case 15://wait badmark inspect
                    {
                        clsMachine.qtMsgShow("处理-BadMark-" + WorkingProcess.iCounter / TimerSpan);

                        isInspectReadyToGo();
                    }
                    break;

                case 16://judge badmark
                    {
                        clsMachine.theMain.repaint();

                        string strAlarm = doCheckBadmark();//wells0188

                        if (!string.IsNullOrEmpty(strAlarm))
                        {
                            clsMachine.qtShowAlarm(strAlarm);
                            WorkingProcess.bEnd = true;
                        }
                        WorkingProcess.iStep++;
                    }
                    break;

                case 17://inspect pinmark
                    {
                        if (!doInspectPart_FOV(tagViewType.PinMarkView))
                        {
                            WorkingProcess.bEnd = true;
                        }

                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;

                case 18:
                    {
                        isReadyToGo();
                    }
                    break;

                case 19://wait pinmark inspect
                    {
                        clsMachine.qtMsgShow("处理-PinMark-" + WorkingProcess.iCounter / TimerSpan);

                        isInspectReadyToGo();
                    }
                    break;

                case 20://judge pinmark
                    {
                        clsMachine.theMain.repaint();

                        if (clsMachine.m_pAllPcb[0].m_pinMarkError > 0)
                        {
                            clsMachine.qtShowAlarm(clsMachine.m_pAllPcb[0].Side.ToString() + "子基板<" + clsMachine.m_pAllPcb[0].m_pinMarkError + ">MARK点错误！请调试程序！");
                            WorkingProcess.bEnd = true;
                            return;
                        }
                        else
                        {
                            clsMachine.m_pAllPcb[0].calPinMarkResult();
                            clsMachine.m_pAllPcb[0].adjustPartsAndFovs_PinMark();

                            clsMachine.theMain.repaint();

                            WorkingProcess.iStep++;
                        }
                    }
                    break;

                case 21://inspect barcode
                    {
                        if (!doInspectPart_FOV(tagViewType.BarcodeView))
                        {
                            WorkingProcess.bEnd = true;
                        }

                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;

                case 22:
                    {
                        isReadyToGo();
                    }
                    break;

                case 23://wait barcode inspect
                    {
                        clsMachine.qtMsgShow("处理-Barcode-" + WorkingProcess.iCounter / TimerSpan);

                        isInspectReadyToGo();
                    }
                    break;

                case 24:
                    {
                        if (!clsMachine.updateBarcodeInfo(false))
                        {
                            WorkingProcess.bEnd = true;
                            break;
                        }

                        clsMachine.m_pAllPcb[0].updateShieldBoxs();

                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;
                #region 老版本暂时不删除
                case 25: // 产品入站操作流程
                    {
                        clsMachine.Customer.productIn();

                        WorkingProcess.iStep++;
                    }
                    break;
                case 26: // 用于判断入站后会否可以继续执行
                    {
                        if (!clsMachine.Customer.CanContinue(ref WorkingProcess.iStep))
                        {
                            WorkingProcess.bEnd = true;
                            break;
                        }
                    }
                    break;
                #endregion
                case 27:
                    ExecutePlugin(Method.ProductIn);
                    break;
                case 28:
                    WorkingProcess.iStep += 1;
                    WorkingProcess.iCounter = 0;
                    break;
                case 30:
                    ExecutePlugin(Method.AfterProductIn);
                    break;
                case 31://inspect part
                    {
                        if (!doInspectPart_FOV(tagViewType.PartView))
                        {
                            WorkingProcess.bEnd = true;
                        }

                        WorkingProcess.iStep++;
                        WorkingProcess.iCounter = 0;
                    }
                    break;

                case 32:
                    {
                        isReadyToGo();
                    }
                    break;

                case 33:
                    {
                        clsMachine.aiSaveImage();
                        clsMachine.moveHome(0, false, true);

                        WorkingProcess.iStep++;
                    }
                    break;

                case 34://wait part inspect
                    {
                        clsMachine.qtMsgShow("处理-Part-" + WorkingProcess.iCounter / TimerSpan);

                        isInspectReadyToGo();
                    }
                    break;

                case 35:
                    {
                        doInspectVirtualPart();

                        WorkingProcess.iStep++;
                    }
                    break;

                case 36:
                    {
                        clsMachine.qtMsgShow("处理-VirtualPart-" + WorkingProcess.iCounter / TimerSpan);

                        isInspectReadyToGo();
                    }
                    break;

                case 37:
                    {
                        if (!doNGMark())
                            break;

                        clsMachine.theMain.repaint();
                        WorkingProcess.iStep++;
                    }
                    break;
                case 38:
                    ExecutePlugin(Method.BeforeProductOut);
                    break;
                case 39://wait work done
                    {
                        if (clsThreadPool.WorkPool.isBusy())
                        {
                            clsMachine.qtMsgShow("等待图片传输" + WorkingProcess.iCounter / TimerSpan);
                            WorkingProcess.iCounter++;
                        }
                        else
                        {
                            clsMachine.theMain.repaint();
                            WorkingProcess.iStep++;
                            WorkingProcess.iCounter = 0;
                        }
                    }
                    break;

                case 40://wait ai done
                    {
                        clsMachine.qtMsgShow("等待 AI 计算" + WorkingProcess.iCounter / TimerSpan);

                        if (clsThreadPool.AIPool.isBusy())
                        {
                            WorkingProcess.iCounter++;
                        }
                        else
                        {
                            WorkingProcess.iStep++;
                            WorkingProcess.iCounter = 0;
                        }
                    }
                    break;

                case 41:
                    {
                        if (Interlocked.Read(ref clsStatus.l_Is_InlineDebug_Enable) != 0)
                        {
                            clsMachine.theMain.enterInlineDebug();
                        }

                        WorkingProcess.iStep++;
                    }
                    break;

                case 42:
                    {
                        if (Interlocked.Read(ref clsStatus.l_Is_InlineDebug_Entered) != 0)
                        {
                            clsMachine.qtMsgShow("在线调试" + WorkingProcess.iCounter / TimerSpan);
                            WorkingProcess.iCounter++;
                        }
                        else
                        {
                            WorkingProcess.iCounter = 0;
                            WorkingProcess.iStep++;
                        }
                    }
                    break;

                case 43:
                    {
                        clsMachine.qtMsgShow("上传检测结果");

                        clsMachine.aiDone(swInspect);//wells0103

                        WorkingProcess.iStep++;
                    }
                    break;
                case 44:
                    ExecutePlugin(Method.ProductOut);
                    break;
                case 45:
                    {
                        if (clsParam.thePublic.SystemProperty.UseInline && WorkingProcess.bAuto)//wells0103
                        {
                            if (clsMachine.nowPcb.results.Count == 0 && clsMachine.nowPcb.results_2d.Count == 0)
                            {
                                outputOKNGSignal(tagOutputOkNg.OK);

                                WorkingProcess.iStep++;
                                WorkingProcess.iStep++;
                            }
                            else
                            {
                                clsMachine.theMotion.setLight(tagMachineLightingStatus.STA_Warning);//wells0048
                                WorkingProcess.iStep++;
                            }
                        }
                        else
                        {
                            outputOKNGSignal(tagOutputOkNg.Judge);

                            WorkingProcess.iStep++;
                        }
                    }
                    break;

                case 46://wait ai done
                    {
                        if (clsParam.thePublic.SystemProperty.UseInline && WorkingProcess.bAuto)//wells0103
                        {
                            if (clsMachine.theMotion.getDi(tagGetCommand.MotorReset))
                            {
                                clsMachine.theMotion.setLight(tagMachineLightingStatus.STA_Waiting);//wells0048
                                clsMachine.theMotion.setDo(tagDoCommand.ResetBtnLight, true);
                            }

                            clsMachine.qtMsgShow("等待人工确认结果" + WorkingProcess.iCounter / TimerSpan);

                            int ret = clsMachine.aiConfirmDone();

                            if (ret == 0)//wells0042
                            {
                                WorkingProcess.iCounter++;
                            }
                            else
                            {
                                outputOKNGSignal(ret == 1 ? tagOutputOkNg.OK : tagOutputOkNg.NG);

                                clsMachine.theMotion.setLight(tagMachineLightingStatus.STA_Running);//wells0048
                                clsMachine.theMotion.setDo(tagDoCommand.ResetBtnLight, false);
                                WorkingProcess.iCounter = 0;
                                WorkingProcess.iStep++;
                            }
                        }
                        else
                        {
                            WorkingProcess.iStep++;
                        }
                    }
                    break;
                case 47:
                    ExecutePlugin(Method.AfterProductOut);
                    break;
                case 48://
                    {
                        if (WorkingProcess.bAuto)
                        {
                            if (WorkingProcess.mode == tagFlowMode.mode_Normal || WorkingProcess.mode == tagFlowMode.mode_Pass || WorkingProcess.mode == tagFlowMode.mode_Loop || WorkingProcess.mode == tagFlowMode.mode_ExitToExit)
                            {
                                WorkingProcess.seq = tagSequence.seq_UnloadToExit;
                                WorkingProcess.iStep = 0;
                                WorkingProcess.iCounter++;
                            }
                            else if (WorkingProcess.mode == tagFlowMode.mode_EntranceToEntrance || WorkingProcess.mode == tagFlowMode.mode_ExitToEntrance || WorkingProcess.mode == tagFlowMode.mode_PassReverse)
                            {
                                WorkingProcess.seq = tagSequence.seq_UnloadToEntrance;
                                WorkingProcess.iCounter = 0;
                                WorkingProcess.iStep = 0;
                            }
                            else if (WorkingProcess.mode == tagFlowMode.mode_LoopNoMoveBoard)
                            {
                                WorkingProcess.iStep = 0;
                                WorkingProcess.iCounter = 0;
                            }

                            if ((WorkingProcess.iFlag & tagFlag.EndAfterInspect) == tagFlag.EndAfterInspect)
                                WorkingProcess.bEnd = true;
                        }
                        else
                        {
                            WorkingProcess.bEnd = true;
                        }
                    }
                    break;
            }

            #endregion
        }